<?php
	defined('_JEXEC') or die('Restricted access');
	require_once(CUTEENGINE_BASE_FIELD_PATH."base_field_class.php");
    
	//
    // t_field_button
    //
	class t_field_button extends t_base_field
	{
        // property declaration
		// public
		const language_position_last = 1;
		
		// P
        const proper_properties_position_per_disabled = 1;
        const proper_properties_position_per_label = 2;        
        const proper_properties_position_last = 3;        
        // property declaration
		// protected		

        // method declaration
    	// protected

        // G
		protected function get_field_event_script($a_event_type,$a_argouments)
        {			
			$local_return = '';
			return $local_return;
		}
                
        // G
        static function get_help_proper_property($a_index)
		{
			$local_return = 'NO HELP AVAILABLE';
			/*switch ($a_index) 
            {
                case self::proper_properties_position_:
					$local_return = '';
				break;                
			}*/
			return $local_return;
		}
        static function get_default_proper_property($a_index)
		{
			$local_return = '';
			/*switch ($a_index) 
            {
                case self::proper_properties_position_:
					$local_return = 'TRUE';
				break;                
			}*/
			return $local_return;
		}
		protected function get_proper_properties_position_last()      
		{
            return self::proper_properties_position_last;
        }
		    
        // method declaration
    	// public
        public function __construct($a_parent_part,$a_common_properties_str, $a_proper_properties_str) 
		{
            parent::__construct($a_parent_part,$a_common_properties_str, $a_proper_properties_str);
            //
          //  echo "a_proper_properties_str(".count($this->proper_properties_array)."): $a_proper_properties_str <BR>";
          //  if ((count($this->proper_properties_array)-1) != (self::proper_properties_position_last))    
            //    throw new Exception('Error creating class '.get_class($this).'. Not enough proper properties were specified.');
            
			
		}

		// C		
		public function create_tags_structure()
        {
            //echo __METHOD__."<BR>";
            parent::create_tags_structure();
            $local_current_tag = parent::add_tag(t_base_tag_type::btt_button,
                $this->common_properties_array[t_base_field::common_properties_position_per_field_name]);
            $local_current_tag->set_text_to_include(
                $this->proper_properties_array[self::proper_properties_position_per_label]);
            $local_enabled = strtolower($this->proper_properties_array[self::proper_properties_position_per_disabled]); 
			if($local_enabled === 'true')
				$local_current_tag->add_property('disabled',
					$this->proper_properties_array[self::proper_properties_position_per_disabled]);
            $this->main_tag = $local_current_tag;  
           // echo "field name: $this->name - default_start_tag: ".$this->main_tag->name."<BR>";
            $this->default_start_tag = $this->main_tag;
            $this->default_result_tag = $this->main_tag;          
            //echo "MAIN FIELD TAG TROVATO";
            
        }
		// C
		public function create_javascript_initialization_component()
		{
		
		}
        
        // G
		public function get_included_in_html_structure($a_name,$a_display,$a_key_tag_name)
		{
			parent::get_included_in_html_structure($a_name);
			if ($a_display)
			{
				$this->main_tag->add_style_property('display','');
			}
			else
			{
				$this->main_tag->add_style_property('display','none');
			}	
			$this->key_tags_list[$a_name] = $a_key_tag_name;
			//echo "a_name: $a_name - a_key_tag_name: $a_key_tag_name<br>";
			$local_label_script = '';
			return ($this->main_tag->generate_html_code_with_new_name($a_name)) ;
		}
		public function get_event_name()
        {

            return /*get_class($this)*/$this->name . "_event_".$this->get_event_type('');
        }
        public function get_event_type($a_action_name)
        {	
			return t_base_field::field_event_type_on_selected;
			
		}
		public function get_language_position_last()
        {
            return self::language_position_last;
        }
        public function get_result_action_script($a_event_type,$parent_event_type,
            $a_parameter,$a_content_loader_result)
		{
            return '';
        }
        // I
		public function initialize_field_event($a_event_type)
        {			
			/*global $g_javascript_namespace;
            global $g_strings_utility_namespace;
            global $g_url_parameters_namespace;
            $local_parameter = $g_url_parameters_namespace->get_parameter_by_component_id($this->parent_component->id);
			$local_event = $this->events[$a_event_type];
			echo "local_event->event_name: ".$local_event->event_name." - local_event->event_type: $local_event->event_type<br>";
			switch ($local_event->event_type) 
            {
                /***********  t_base_field::field_event_type_on_selected  ***********               
				case t_base_field::field_event_type_on_selected:
					$g_javascript_namespace->header_script_generator->add_method_to_a_class_with_content(
						get_class($this),$local_event->event_name,'event',"
       var local_argoument = '".t_url_parameter::separator_level_0 . "' + '$local_parameter->argument';
       ".$local_event->body_code."
       ");
					$this->default_start_tag->add_property("onclick",t_cuteengine::javascript_instance_name.".".$this->name.".".$local_event->event_name."(event)");
				break;

			}	
		*/	
		}		    
        
    }
?>    